Skip to content

Allow command calls in endless method bodies within assignments#3601

Merged
tenderlove merged 1 commit into
ruby:mainfrom
Shopify:fix-3473
Jul 29, 2025
Merged

Allow command calls in endless method bodies within assignments#3601
tenderlove merged 1 commit into
ruby:mainfrom
Shopify:fix-3473

Conversation

@st0012

@st0012 st0012 commented Jul 17, 2025

Copy link
Copy Markdown
Member

(This is another attempt to solve #3473 as #3598 caused ruby/ruby tests to fail and got reverted)

Previously, endless method definitions in assignment contexts like x = def f = p 1 would fail to parse because command calls (method calls without parentheses) were only accepted when the surrounding binding power was less than PM_BINDING_POWER_COMPOSITION.

This fix specifically checks for assignment context and allows command calls in those cases while maintaining the existing behavior for other contexts. This ensures that:

  • x = def f = p 1 parses correctly (previously failed)
  • private def f = puts "Hello" still produces the expected error

@rafaelfranca rafaelfranca added the Need another review Need an extra review label Jul 17, 2025
Comment thread src/prism.c
Previously, endless method definitions in assignment contexts like
`x = def f = p 1` would fail to parse because command calls (method
calls without parentheses) were only accepted when the surrounding
binding power was less than `PM_BINDING_POWER_COMPOSITION`.

This fix specifically checks for assignment context and allows command
calls in those cases while maintaining the existing behavior for other
contexts. This ensures that:

- `x = def f = p 1` parses correctly (previously failed)
- `private def f = puts "Hello"` still produces the expected error
@tenderlove
tenderlove merged commit 3e8066e into ruby:main Jul 29, 2025
58 checks passed
@st0012
st0012 deleted the fix-3473 branch July 29, 2025 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Need another review Need an extra review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants